package xyz.wongs.gry.synx.thread

import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit

/**
 * @ClassName ResultCode 定义的接口状态码
 * @Description
 * @author WCNGS@QQ.COM
 * @Github <a> https://github.com/rothschil</a>
 * @date 2020/12/23 11:31
 * @Version 1.0.0
 */
CountDownLatch cdl = new CountDownLatch(1)

def first = Thread.start {
    cdl.await()
    println("【多线程】 First "+Thread.currentThread().getName())
}

def second = Thread.start {
    TimeUnit.SECONDS.sleep(2)
    println("【多线程】 Second "+Thread.currentThread().getName())
    cdl.countDown()
}
// 先启动第一个线程
first
// 再启动第二个线程
second